//导入实例对象request中instance= axios
// 抽取封装，统一管理请求api
import instance from './request'

// 主页登陆
export const Login = (params) => instance.post('/login', params)

// 导航侧边栏
export const Menus = () => instance.get('/menus')

// 获取用户列表
export const UserList = (params) => instance.get('/users', params)

// 修改用户数据
export const ChangeUserInfo = (userId, mg_state) => instance.put(`/users/${userId}/state/${mg_state}`)

// 添加用户
export const AddUser = (params) => instance.post('/users', params)
// 编辑设置用户信息

export const EditUserInfo = (id) => instance.get(`/users/${id}`)

// 修改用户信息提交数据
export const EditUserInfoPost = (id, params) => instance.put(`/users/${id}`, params)

// 删除用户信息 
export const RemoveUser = (id) => instance.delete(`/users/${id}`)

// 用户分配角色
export const UserRoles = () => instance.get('/roles')

// 提交角色
export const PostUser = (id, params) => instance.put(`/users/${id}`, params)

// 权限

// 获取权限列表
export const Rights = () => instance.get('rights/list')

// 获取角色权限列表
export const Roles = () => instance.get('/roles')

// 删除点击所在的权限
export const RolesRights = (id1, id2) => instance.delete(`roles/${id1}/rights/${id2}`)

// 获取权限分配
export const RightsDealing = () => instance.get(`rights/tree`)

// 分配权限提交数据
export const AssinRight = (id, params) => instance.post(`roles/${id}/rights`, params)

// 提交角色信息
export const AddRole = (params) => instance.post('/roles', params)

// 删除角色列表项
export const RemoveRoles = (RowId) => instance.delete(`roles/${RowId}`)

// 编辑角色
export const EditRole = (id, params) => instance.put(`roles/${id}`, params)


// 商品管理

// 获取商品信息
export const GetGoodsList = (params) => instance.get('/goods', { params })

// 确认编辑信息提交
export const ConfirmEditInfo = (id, params) => instance.put(`/goods/${id}`, params)

// 删除商品
export const RemoveGoods = (id) => instance.delete(`goods/${id}`)

// 添加商品

// 请求商品分类

export const GetGoodsSort = () => instance.get(`/categories`)

// 被选中时候出发
export const TabClick = (cateId, params) => instance.get(`/categories/${cateId}/attributes`, { params })

// 添加商品 图片
export const PostAddImages = (params) => instance.post('/goods', params)

// 请求及联选择框的数据
export const getParams = () => instance.get('/categories')

// 请求商品分类数据
export const getUserInfo = (params) => instance.get('/categories', params)

// 获取父级分类列表
export const GetFather = (params) => instance.get('/categories', params)

// 添加商品
export const AddGoods = (parmas) => instance.post('/categories', parmas)

// 编辑商品确认提交
export const EditGoods = (tableCurrentId, params) => instance.put(`categories/${tableCurrentId}`, params)

// 删除当前的分类名称
export const RemoveGoodsCate = (cat_id) => instance.delete(`/categories/${cat_id}`)

// 获取参数的列表数据 切换
export const ChangeParams = (cateId, params) => instance.get(`/categories/${cateId}/attributes`, { params })

// 提交动态或静态
export const SetParamsInfo = (id, params) => instance.post(`/categories/${id}/attributes`, params)

// 二级权限的id
//  请求添加属性的值
export const SetParamsTow = (cateId, attr_id, params) => instance.put(`/categories/${cateId}/attributes/${attr_id}`, params)

// 删除参数
export const RemoveParamsInfo = (cateId, attrId) => instance.delete(`/categories/${cateId}/attributes/${attrId}`)

// 添加/删除参数
export const NewDeleteParams = (cateId, attr_id, params) => instance.put(`/categories/${cateId}/attributes/${attr_id}`, params)

// 订单

// 获取商品订单列表
export const GetOrder = (params) => instance.get(`/orders`, params)

// 订单地址
export const OrderPath = () => instance.get(`/kuaidi/1106975712662`)


// 数据统计
export const GetReport = () => instance.get(`/reports/type/1`)